<%@page import="beans.util.ExtendedDataTableBean"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib prefix="a4j" uri="http://richfaces.org/a4j"%>
<%@taglib prefix="rich" uri="http://richfaces.org/rich"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<f:view>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title><h:outputText value="#{msg.show_next_visits} - #{msg.medic}: #{extendedDataTableBean.username} (#{extendedDataTableBean.nome} #{extendedDataTableBean.cognome})" /></title>
            <link href="<% out.print(request.getContextPath());%>/resources/css/position.css" rel="stylesheet" type="text/css" />
            <% ExtendedDataTableBean med = ((ExtendedDataTableBean) session.getAttribute("extendedDataTableBean")); 
               med.invalidPats(); med.setPerformedF(false); %>
        </head>
        <body>
            <jsp:include page="/pages/fragments/header.jsp" />
            <jsp:include page="/pages/fragments/medicMenu.jsp" />
            
            <section>
                
                    <h:panelGrid id="all" columns="2" columnClasses="col, col">
                        <rich:panel header="#{msg.patients_list}" style="width: 670px">
                            <a4j:form id="patients_waiting_exam">
                                <rich:extendedDataTable id="visite" value="#{extendedDataTableBean.waitingExaminationsDataModel}" var="ex"
                                                    width="650px" height="550px" selectionMode="single" rows="17" footerClass="ds"
                                                    selection="#{extendedDataTableBean.selectionExam}" columnClasses="b2,b2,b2,b2,b2,b2">
                                <f:facet name="header">
                                    <h:outputText value="#{msg.examinations}" />
                                </f:facet>
                                <rich:column width="40px" sortBy="#{ex.id}">
                                    <f:facet name="header">
                                        <h:outputText value="Id" />
                                    </f:facet>
                                    <h:outputText value="#{ex.id}" />
                                </rich:column>
                                    <rich:column width="100px">
                                    <f:facet name="header">
                                        <h:outputText value="#{msg.patient}" />
                                    </f:facet>
                                    <h:outputText value="#{extendedDataTableBean.getPatientFromExam(ex)}" />
                                </rich:column>
                                <rich:column width="110px" sortBy="#{ex.tipo}">
                                    <f:facet name="header">
                                        <h:outputText value="#{msg.type}" />
                                    </f:facet>
                                    <rich:inplaceSelect defaultLabel="#{msg.charters_slide}"
                                                            value="#{ex.tipo}" editEvent="none">
                                        <f:selectItem itemValue="1" itemLabel="#{msg.prog_exam}" />
                                        <f:selectItem itemValue="2" itemLabel="#{msg.vaccination}" />
                                        <f:selectItem itemValue="3" itemLabel="#{msg.voluntary}" />
                                    </rich:inplaceSelect>
                                </rich:column>
                                <rich:column sortBy="#{ex.scadenza}">
                                    <f:facet name="header">
                                        <h:outputText value="#{msg.expirationDate}" />
                                    </f:facet>
                                    <h:outputText value="#{ex.scadenza}">
                                        <f:convertDateTime type="date" dateStyle="long" />
                                    </h:outputText>
                                </rich:column>
                                <rich:column id="cent-style" width="140px" sortBy="#{ex.tipo_scadenza}">
                                    <f:facet name="header">
                                        <h:outputText value="#{msg.expirationType}" />
                                    </f:facet>
                                    <rich:inplaceSelect defaultLabel="#{msg.charters_slide}"
                                                        value="#{ex.tipo_scadenza}" editEvent="none">
                                        <f:selectItem itemValue="1" itemLabel="#{msg.periodic}" />
                                        <f:selectItem itemValue="2" itemLabel="#{msg.prog_med}" />
                                        <f:selectItem itemValue="3" itemLabel="#{msg.prog_bd}" />
                                    </rich:inplaceSelect>
                                </rich:column>
                                <rich:column sortBy="#{ex.descrizione}">
                                    <f:facet name="header">
                                        <h:outputText value="#{msg.description}" />
                                    </f:facet>
                                    <h:outputText value="#{ex.descrizione}" />
                                </rich:column>
                                    <rich:column filterExpression="#{extendedDataTableBean.performedF==ex.effettuata}" width="60px">
                                    <f:facet name="header">
                                        <h:outputText value="  #{msg.performed}" />
                                    </f:facet>
                                    <h:selectBooleanCheckbox id="performed" value="#{ex.effettuata}" disabled="true"/>
                                </rich:column>
                                <f:facet name="footer">
                                    <rich:datascroller id="ds" for="visite"></rich:datascroller>
                                </f:facet>
                                <a4j:support reRender="patients_waiting_exam, examEdit" id="examinations_detail"
                                             event="onselectionchange"
                                             action="#{extendedDataTableBean.takeExamSelection}" />
                            </rich:extendedDataTable></a4j:form>
                        </rich:panel>
                        <jsp:include page="/pages/fragments/ExaminationEditor.jsp" />
                    </h:panelGrid>
                
            </section>
        </body>
    </html>
</f:view>